package com.rideplans.client.planride;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.maps.client.InfoWindowContent;
import com.google.gwt.maps.client.MapWidget;
import com.google.gwt.maps.client.Maps;
import com.google.gwt.maps.client.control.LargeMapControl;
import com.google.gwt.maps.client.geom.LatLng;
import com.google.gwt.maps.client.overlay.Marker;
import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Label;
import com.rideplans.client.MainView;
public class WizardMaps extends Composite {
	AbsolutePanel absolutePanel;
	AbsolutePanel absolutePanelMap;
	public WizardMaps() {
		absolutePanel = new AbsolutePanel();
		initWidget(absolutePanel);
		absolutePanel.setSize("984px", "785px");
		
		Label lblNewLabel = new Label("Ride Map Details");
		lblNewLabel.setStyleName("gwt-Label-header");
		absolutePanel.add(lblNewLabel, 0, 0);
		lblNewLabel.setSize("984px", "29px");
		
		Button btnNext = new Button("Next");
		absolutePanel.add(btnNext, 935, 751);
		
		Button btnBack = new Button("Back");
		absolutePanel.add(btnBack, 10, 751);
		
		/*
		 * Next Button Clicked
		 */
		btnNext.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				MainView.absolutePanelContent.clear();
				MainView.absolutePanelContent.add(new WizardDailyPlan());
			}
		});
		
		/*
		 * Back Button Clicked
		 */
		btnBack.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				MainView.absolutePanelContent.clear();
				MainView.absolutePanelContent.add(new WizardDetails());
			}
		});
		
		absolutePanelMap = new AbsolutePanel();
		absolutePanel.add(absolutePanelMap, 0, 35);
		absolutePanelMap.setSize("984px", "710px");
		   Maps.loadMapsApi("", "2", false, new Runnable() {
			      public void run() {
			        buildUi();
			      }
			    });
	}
	
	private void buildUi() {
	    // Open a map centered on Cawker City, KS USA
	    LatLng cawkerCity = LatLng.newInstance(39.509, -98.434);

	    final MapWidget map = new MapWidget(cawkerCity, 2);
	    map.setSize("100%", "100%");
	    // Add some controls for the zoom level
	    map.addControl(new LargeMapControl());

	    // Add a marker
	    map.addOverlay(new Marker(cawkerCity));

	    // Add an info window to highlight a point of interest
	    map.getInfoWindow().open(map.getCenter(),
	        new InfoWindowContent("World's Largest Ball of Sisal Twine"));

	   // final DockLayoutPanel dock = new DockLayoutPanel(Unit.PX);
	   // dock.addNorth(map, 500);

	    // Add the map to the HTML host page
	    absolutePanelMap.add(map);
	  }
}
